//
//  ByWithdrawListCell.m
//  caipiao_ios
//
//  Created by mc on 2018/8/15.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByWithdrawListCell.h"

@implementation ByWithdrawListCell

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByWithdrawListCell";
    ByWithdrawListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self initViews];
    }
    return self;
}


- (void)initViews{
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [self.contentView addSubview:iconView];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.centerY.equalTo(self.contentView).offset(0);
        make.size.mas_equalTo(CGSizeMake(45, 45));
    }];
    iconView.image = [UIImage imageNamed:@"tixian-1提现"];
    
    
    UILabel *moneyLabel = [[UILabel alloc] init];
    [self.contentView addSubview:moneyLabel];
    [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(iconView.mas_top).offset(0);
        make.height.mas_equalTo(@20);
        make.width.mas_equalTo(@100);
    }];
    moneyLabel.text = @"100元";
    moneyLabel.font = FONT(12);
    moneyLabel.textColor = [UIColor blackColor];
    moneyLabel.textAlignment = NSTextAlignmentRight;
    
    UILabel *titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).offset(10);
        make.top.equalTo(iconView.mas_top).offset(0);
        make.height.mas_equalTo(@20);
        make.right.equalTo(moneyLabel.mas_left).offset(-10);
    }];
    
    titleLabel.font = FONT(14);
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    
    UILabel *timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_left).offset(0);
        make.bottom.equalTo(iconView.mas_bottom).offset(0);
        make.height.mas_equalTo(@20);
        make.right.equalTo(titleLabel.mas_right).offset(0);
    }];
    timeLabel.text = @"2018-05-28";
    timeLabel.font = FONT(12);
    timeLabel.textColor = [UIColor lightGrayColor];
    timeLabel.textAlignment = NSTextAlignmentLeft;
    
    UILabel *stateLabel = [[UILabel alloc] init];
    [self.contentView addSubview:stateLabel];
    [stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(moneyLabel.mas_left).offset(0);
        make.bottom.equalTo(iconView.mas_bottom).offset(0);
        make.height.mas_equalTo(@20);
        make.right.equalTo(moneyLabel.mas_right).offset(0);
    }];
    stateLabel.text = @"打款完成";
    stateLabel.font = FONT(12);
    stateLabel.textColor = [UIColor lightGrayColor];
    stateLabel.textAlignment = NSTextAlignmentRight;
    self.titleLabel = titleLabel;
    self.timeLabel = timeLabel;
    self.stateLabel = stateLabel;
    self.moneyLabel = moneyLabel;
}

- (void)setNetModel:(ByNetModel *)netModel{
    _netModel = netModel;

    self.titleLabel.text = [NSString stringWithFormat:@"提现到%@", netModel.account];;
    self.moneyLabel.text = [NSString stringWithFormat:@"%@元",netModel.user_money];
    self.timeLabel.text = [NSDate getDateStringFromeNumber:[NSNumber numberWithInteger:netModel.add_time.integerValue]];
    if (netModel.status.integerValue == 0) {
        self.stateLabel.text = @"审核中";
        self.stateLabel.textColor = BY_THEME_COLOR;
    }else if (netModel.status.integerValue == 1){
        self.stateLabel.textColor = rgba(109, 177, 10, 1);
        self.stateLabel.text = @"打款成功";
    }else if (netModel.status.integerValue == 2){
        self.stateLabel.text = @"提现失败";
        self.stateLabel.textColor = BY_THEME_COLOR;
    }
}

@end
